package day04;

import java.util.Random;
import java.util.Scanner;

public class CommandBySwitch {
    public static void main(String[] args) {

        for (int i = 0; i < 5; i++) {
            System.out.println("行动是成功的阶梯");
        }
        int num = 9;
        for (int i = 0; i <= 9; i++) {
            int number = num * i;
            System.out.println(num+ "*"+ i+"=" + number);

        }
        for (int i = 1; i <= 9; i+=2) {
            int number = num * i;
            System.out.println(num+ "*"+ i+"=" + number);

        }
        for (int i = 9; i >=0 ; i--) {
            int number = num * i;
            System.out.println(num+ "*"+ i+"=" + number);

        }

        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int guess = r.nextInt(200) + 1;
        System.out.println(guess);
        do {
            System.out.println("请输入");
            int userNumber = sc.nextInt();
            if (userNumber > 1 && userNumber < 200) {
                if (userNumber > guess) {
                    System.out.println("猜大了");
                } else if (userNumber < guess) {
                    System.out.println("猜小了");
                } else {
                    System.out.println("猜中了");
                    break;
                }
            } else {
                System.out.println("超出范围");
            }
        }
        while (true);

        System.out.println("请输入");
        int command = sc.nextInt();
        int userNumber = sc.nextInt();

        while (true) {
            System.out.println("请输入");
            int userNumber1 = sc.nextInt();
            if (userNumber1 > 1 && userNumber1 < 200) {
                if (userNumber1 > guess) {
                    System.out.println("猜大了");
                } else if (userNumber1 < guess) {
                    System.out.println("猜小了");
                } else {
                    System.out.println("猜中了");
                    break;
                }
            } else {
                System.out.println("超出范围");
            }
        }
    }
}
